Repository navigation
Remove the support for event, command and snapshot JSON in text columns - #559
Merged
Merged
Conversation
Since Sequent 8 the event store keeps the JSON of events, commands and snapshots in jsonb columns, and the event_records and command_records views are part of Sequent's schema, so the branches for JSON in a text column were no longer used. The event store now deserializes loaded events directly from their JSON, instead of assigning it to a new event_record_class instance first.
There was a problem hiding this comment.
🟡 Changes recommended
Accessor-backed event and command records retain raw Time values instead of JSON-normalized strings, causing subsequent deserialization to fail.
1 open issue
What changed in this PR
This PR removes legacy text-column JSON support now that Sequent’s event store uses jsonb, simplifying record serialization and speeding up event loading.
Changes:
- Remove text-column serialization helpers from event, command, and snapshot records.
- Deserialize loaded events directly without creating intermediate record instances.
- Update serialization specs and document the breaking changes.
| File | Description |
|---|---|
spec/lib/sequent/core/serializes_event_spec.rb |
Expect event payloads as hashes. |
spec/lib/sequent/core/serializes_command_spec.rb |
Expect hashes and remove legacy serialization overrides. |
lib/sequent/core/snapshot_record.rb |
Remove snapshot column-type detection. |
lib/sequent/core/event_store.rb |
Deserialize events without intermediate records. |
lib/sequent/core/event_record.rb |
Remove text-JSON conversion and serialization helpers. |
lib/sequent/core/command_record.rb |
Remove text-JSON conversion and column-type detection. |
CHANGELOG.md |
Document compatibility changes and loading performance gains. |
Review effort: Balanced
A record that includes SerializesEvent or SerializesCommand without being an ActiveRecord model with a json column, like one using attr_accessor, kept the Time values of the attributes, and could not load the event or command again. as_json gives the values they are loaded from; ActiveRecord's json type casts them the same way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Since Sequent 8 the event store keeps the JSON of events, commands and snapshots in jsonb columns of its own schema, so the support for JSON in text columns is dead code that still costs something: every loaded event was assigned to a new
event_record_classinstance just to be deserialized. Removing it simplifies the records and makes loading events about 40% faster.Measured with an event of 10 attributes (including a value object and arrays):
deserialize_eventwent from 24 to 14 µs and from 179 to 141 allocations per event, andload_eventsof 2,000 events from 30 to 19 µs per event. This is a breaking change for applications with their own record classes relying onserialize_json?orserialize_to_json, described in the changelog.